﻿using SD.Infrastructure.EntityBase;
using System;
using System.Text;
using SlamDunk.ValueObjects.Enums;

namespace SlamDunk.MES.Domain.Entities.ResourceContext
{
    /// <summary>
    /// 企业
    /// </summary>
    public class Enterprise : AggregateRootEntity
    {
        #region # 构造器

        #region 00.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected Enterprise() { }
        #endregion

        #region 01.创建企业构造器
        /// <summary>
        /// 创建企业构造器
        /// </summary>
        /// <param name="enterpriseNo">企业编号</param>
        /// <param name="enterpriseName">企业名称</param>
        /// <param name="enterpriseType">企业类型</param>
        /// <param name="facilityId">工厂模型Id</param>
        /// <param name="address">联系地址</param>
        /// <param name="phone">联系电话</param>
        /// <param name="contact">联系人</param>
        /// <param name="fax">传真</param>
        /// <param name="legalPerson">法人</param>
        /// <param name="licenseNo">营业执照编号</param>
        /// <param name="description">描述</param>
        public Enterprise(string enterpriseNo, string enterpriseName, EnterpriseType enterpriseType, Guid? facilityId, string address, string phone, string contact, string fax, string legalPerson, string licenseNo, string description)
            : this()
        {
            base.Number = enterpriseNo;
            base.Name = enterpriseName;
            this.EnterpriseType = enterpriseType;
            this.FacilityId = facilityId;
            this.Address = address;
            this.Phone = phone;
            this.Contact = contact;
            this.Fax = fax;
            this.LegalPerson = legalPerson;
            this.LicenseNo = licenseNo;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #endregion

        #region # 属性

        #region 企业类型 —— EnterpriseType EnterpriseType
        /// <summary>
        /// 企业类型
        /// </summary>
        public EnterpriseType EnterpriseType { get; private set; }
        #endregion

        #region 工厂模型Id —— Guid? FacilityId
        /// <summary>
        /// 工厂模型Id
        /// </summary>
        public Guid? FacilityId { get; private set; }
        #endregion

        #region 联系地址 —— string Address
        /// <summary>
        /// 联系地址
        /// </summary>
        public string Address { get; private set; }
        #endregion

        #region 联系电话 —— string Phone
        /// <summary>
        /// 联系电话
        /// </summary>
        public string Phone { get; private set; }
        #endregion

        #region 联系人 —— string Contact
        /// <summary>
        /// 联系人
        /// </summary>
        public string Contact { get; private set; }
        #endregion

        #region 传真 —— string Fax
        /// <summary>
        /// 传真
        /// </summary>
        public string Fax { get; private set; }
        #endregion

        #region 法人 —— string LegalPerson
        /// <summary>
        /// 法人
        /// </summary>
        public string LegalPerson { get; private set; }
        #endregion

        #region 营业执照编号 —— string LicenseNo
        /// <summary>
        /// 营业执照编号
        /// </summary>
        public string LicenseNo { get; private set; }
        #endregion

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; private set; }
        #endregion

        #endregion

        #region # 方法

        #region 修改企业 —— void UpdateInfo(string enterpriseNo, string enterpriseName...
        /// <summary>
        /// 修改企业
        /// </summary>
        /// <param name="enterpriseNo">企业编号</param>
        /// <param name="enterpriseName">企业名称</param>
        /// <param name="enterpriseType">企业类型</param>
        /// <param name="facilityId">工厂模型Id</param>
        /// <param name="address">联系地址</param>
        /// <param name="phone">联系电话</param>
        /// <param name="contact">联系人</param>
        /// <param name="fax">传真</param>
        /// <param name="legalPerson">法人</param>
        /// <param name="licenseNo">营业执照编号</param>
        /// <param name="description">描述</param>
        public void UpdateInfo(string enterpriseNo, string enterpriseName, EnterpriseType enterpriseType, Guid? facilityId, string address, string phone, string contact, string fax, string legalPerson, string licenseNo, string description)
        {
            base.Number = enterpriseNo;
            base.Name = enterpriseName;
            this.EnterpriseType = enterpriseType;
            this.FacilityId = facilityId;
            this.Address = address;
            this.Phone = phone;
            this.Contact = contact;
            this.Fax = fax;
            this.LegalPerson = legalPerson;
            this.LicenseNo = licenseNo;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(base.Number);
            builder.Append(base.Name);
            builder.Append(this.Address);
            builder.Append(this.Phone);
            builder.Append(this.Contact);
            builder.Append(this.Fax);
            builder.Append(this.LegalPerson);
            builder.Append(this.Description);

            base.SetKeywords(builder.ToString());
        }
        #endregion

        #endregion
    }
}
